﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WorkShop
{
    public partial class ShippingDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblOrderID.Text = Application["OrderID"].ToString();
            lblProductID.Text = Application["ProductID"].ToString();
            double price = Convert.ToDouble(Application["Price"]);
            int quantity = Convert.ToInt32(Application["Quantity"]);
            double amount = price * quantity;
            lblGross.Text = amount.ToString();
            lblDiscount.Text = "0";
            if(Application["Discount"] != null){
                double discount = amount * (Convert.ToInt32(Application["Discount"])) / 100;
                lblDiscount.Text = discount.ToString("####.##");
            }
            lblTaxes.Text = (amount * (12.5 / 100)).ToString("####.##");
            double totalAmount = Convert.ToDouble(lblGross.Text) + Convert.ToDouble(lblTaxes.Text) - Convert.ToDouble(lblDiscount.Text);
            lblAmount.Text = totalAmount.ToString("####.##");
            txtZipCode.Focus();

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Application["Delivery"] = "0";
            if(ddlLocation.SelectedIndex == 1){
                Application["Delivery"] = "15";
            }else if(ddlLocation.SelectedIndex == 2){
                Application["Delivery"] = "25";
            }
            Application["Amount"] = lblAmount.Text;
            Response.Redirect("Notification.aspx");
        }

        protected void btnReset_Click(object sender, EventArgs e)
        {
            txtZipCode.Text = "";
            ddlLocation.SelectedIndex = 0;
            txtZipCode.Focus();
        }
    }
}